#!/bin/bash
#sudo su #切换到root权限
#download jdk-8u191-linux-x64
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.rpm
rpm -ivh jdk-8u191-linux-x64.rpm
#set environment
export JAVA_HOME="/usr/java/jdk-8u191-linux-x64"
if ! grep "JAVA_HOME=/usr/java/jdk-8u191-linux-x64" /etc/profile 
then
    echo "TMOUT=600" >> /etc/profile 
    echo "JAVA_HOME=/usr/java/jdk-8u191-linux-x64" | sudo tee -a /etc/profile 
    echo "export JAVA_HOME" | sudo tee -a /etc/profile 
    echo "PATH=$PATH:$JAVA_HOME/bin" | sudo tee -a /etc/profile 
    echo "export PATH" | sudo tee -a /etc/profile  
    echo "CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" | sudo tee -a /etc/profile 
    echo "export CLASSPATH" | sudo tee -a /etc/profile  
fi

#update profile
echo  "jdk is installed !"
